//
//  UIButton+Extension.swift
//  SinaWeibo25
//
//  Created by Yan on 16/3/14.
//  Copyright © 2016年 itcast. All rights reserved.
//

import UIKit

func buttonWithImage(imageName:String,backImageName:String)->UIButton {
    let button = UIButton()
    button.setImage(UIImage(named: imageName + "_hightlighted"), forState: .Highlighted)
    button.setImage(UIImage(named: imageName), forState: .Normal)
    button.setBackgroundImage(UIImage(named: backImageName), forState: .Normal)
    button.setBackgroundImage(UIImage(named: backImageName + "_hightlighted"), forState: .Highlighted)
    button.sizeToFit()
    return button
}

//背景图片文字颜色字体
func buttonWithTitle(title:String,fontSize:CGFloat,titleColor:UIColor,backImageName:String)->UIButton {
    let button = UIButton()
    button.setTitle(title, forState: .Normal)
    button.setTitleColor(titleColor, forState: .Normal)
    button.setTitleColor(UIColor.darkGrayColor(), forState: .Normal)
    button.titleLabel?.font = UIFont.systemFontOfSize(fontSize)
    button.setBackgroundImage(UIImage(named: backImageName), forState: .Normal)
    button.sizeToFit()
    return button
}

func buttonWithTitle(title:String,fontSize:CGFloat,titleColor:UIColor,imageName:String)->UIButton {
    let button = UIButton()
    button.setTitle(title, forState: .Normal)
    button.setTitleColor(titleColor, forState: .Normal)
    button.setTitleColor(UIColor.darkGrayColor(), forState: .Normal)
    button.titleLabel?.font = UIFont.systemFontOfSize(fontSize)
    button.setImage(UIImage(named: imageName), forState: .Normal)
    button.sizeToFit()
    return button
}